<template>
	<view class="themeItem">
		<navigator
		v-if="!isMore"
		:url="`/pages/classlist/classlist?id=${item._id}&name=${item.name}`"
		class="box"
		>
			<view v-if="time" class="tag">{{time}}前更新</view>
			<!-- 在组件里面使用组件，如果不加类名，可能小程序会报警告错误 -->
			<image class="pic" :src="item.picurl" mode=""></image>
			<view class="mask">{{item.name}}</view>
		</navigator>
		
		<navigator v-else url="/pages/classify/classify" open-type="reLaunch" class="box more">
			<image class="pic" src="/common/images/classify1.jpg" mode=""></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
import { computed } from 'vue'
import { formatRelativeTime } from '@/utils/common.js'
const props = defineProps({
	isMore: {
		type: Boolean,
		default: false
	},
	item: {
		type: Object,
		default(){
			return {
				name: '默认名称',
				picurl: '/common/images/classify1.jpg',
				updateTime: Date.now() - 1000*60*60*5
			}
		}
	}
})

const time = computed(() => formatRelativeTime(props.item.updateTime))
// console.log(time.value)
</script>

<style lang="scss" scoped>
.themeItem {
	.box {
		position: relative;
		height: 340rpx;
		border-radius: 10rpx;
		overflow: hidden;
		.pic {
			width: 100%;
			height: 100%;
			z-index: 1;
		}
		.tag {
			position: absolute;
			left: 0;
			top: 0;
			padding: 6rpx 14rpx;
			font-size: 22rpx;
			color: #fff;
			border-radius: 0 0 20rpx 0;
			background: rgba(250,129,90,.7);
			backdrop-filter: blur(20rpx);
			z-index: 2;
		}
		.mask {
			position: absolute;
			left: 0;
			bottom: 0;
			width: 100%;
			height: 80rpx;
			background-color: rgba(0,0,0,.2);
			color: #fff;
			font-size: 30rpx;
			text-align: center;
			font-weight: 600;
			line-height: 80rpx;
			// 磨砂效果，背景模糊 - blur模糊滤镜
			backdrop-filter: blur(20rpx);
			z-index: 2;
		}
	}
	
	.box.more {
		.mask {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			width: 100%;
			height: 100%;
			.text {
				font-size: 28rpx;
			}
		}
	}
}
</style>